<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title></title>
</head>

<body>
<div>window.location.href:</div>
<div id="div2"></div><br />
</body>
<script type="text/javascript">
window.onload = function() {
	locationHref = window.location.href;
	var map=urlToMap(locationHref);
	var search=window.location.search
	console.log(search);
	console.log(map);
}
/**
 * 将url作用的参数封装成map,并返回map
 * @param {Object} url
 */
function urlToMap(url){
	var index=url.indexOf("?")+1;
	var queryString=url.substring(index);
	var array=queryString.split("&");
	var map=new Map();
	for(var i=0;i<array.length;i++){
		var kv=array[i].split("=")
		map.set(kv[0],kv[1]);
	}
	return map;
}
</script>

</html>